package jwr.ex6;
import java.util.Scanner;


public class JDBCPracticeMain {
	private final static String MENU = "추가(1), 삭제(2), 수정(3), 조회(4) 끝내기(5)>>";
	private final static String ADDMENU = "id, 책 제목, 출판사, 저자 정보를 차례대로 입력>>";
	private final static String DELETEMENU = "삭제할 id를 입력>>";
	private final static String UPDATEMENU = "수정할 속성의 이름(id, title, publisher, author), 속성의 현재 값, 새로운 값 입력>>";
	
	
	public static void main(String args[]){
		JDBCpractice jc = new JDBCpractice();
		Scanner sc = new Scanner(System.in);
		
		
		while(true){
			System.out.print(MENU);
			switch(sc.nextInt()){
				case 1:
					System.out.print(ADDMENU);
					jc.insertJDBC(sc.nextInt(), sc.next(), sc.next(), sc.next());
					break;
				case 2:
					System.out.print(DELETEMENU);
					jc.deleteJDBC(sc.nextInt());
					break;
				case 3:
					System.out.println(jc.selectJDBC());
					System.out.println(UPDATEMENU);
					if(jc.updateJDBC(sc.next(), sc.next(), sc.next()))
						System.out.println("성공");
					else{
						System.out.println("실패");
					}
					break;
				case 4:
					System.out.print(jc.selectJDBC());
					break;
				case 5:
					sc.close();
					System.exit(0);
					break;
			}
		}
		
//		boolean b= jc.insertJDBC();
//		System.out.println(b);
//		jc.updateJDBC();
//		jc.deleteJDBC();
//		System.out.println(jc.selectJDBC());
		
	}
}
